var _settings = {};

$("#add_activity").click( function() {
	if (_settings.addActivityState == undefined || _settings.addActivityState === false) {
		$("#chronoses").prepend("<div class='dragable'><input id='newChronos' type='text'/></div>");
		_settings.addActivityState = true;
		$("#newChronos").focus();
		$("#newChronos").focusout(function(e) { 
			/* => API (Add chronos to the database) */
			var result = this.value;
			if(result !== undefined && result !== '') {
				$.post('/api/', {name : result}, function(data) {
					alert("data loaded" + data);
				});
			}
			});
		$("#newChronos").keydown(function (e) { if(e.keyCode === 13) { /* => API (Add chronos to the server*/ }});
	} else {
		$("#newChronos").focus();
	}
});

$("div.dragable").hover(function() {console.log(this + " element in");}, function() {console.log(this + "element out");});

$("div.dragable").click(function(e) {
	$(this).slideUp();
});

$("div.activity").click(function(e) {
	$.get("/xhr", function(data) {
		$("#timer").text(data);
	});
	console.log("activity was pressed");
});

$("div.activity").hover(function(e) {
	$(this).removeClass("default_act").addClass("focused_act");
},
						function(e) {
	$(this).removeClass("focused_act").addClass("default_act");
});